package com.heh.mybatisplus;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.heh.mybatisplus.model.EmpId;
import com.heh.mybatisplus.service.EmpIdService;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.List;

@MapperScan("com.heh.mybatisplus.mapper")
@SpringBootApplication
@Slf4j
public class MybatisPlusApplication implements ApplicationRunner {
    @Autowired
    private EmpIdService empIdService;
    @Autowired
    private ObjectMapper objectMapper;
    void query() {
        List<EmpId> list = empIdService.list();
        try {
            log.info("============{}", objectMapper.writeValueAsString(list));
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }

    }
    @Override
    public void run(ApplicationArguments args) throws Exception {
        query();
    }



    public static void main(String[] args) {
        SpringApplication.run(MybatisPlusApplication.class, args);
    }

}
